package com.asset.dispoal.business.mediation.service.common;

import com.asset.dispoal.business.mediation.domain.db.entity.ReduceOperate;
import com.asset.dispoal.business.mediation.domain.db.mapper.ReduceOperateMapper;
import com.asset.dispoal.business.mediation.dto.ReduceDtailInfoResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.core.util.StringUtil;
import tech.mhuang.pacebox.springboot.protocol.Result;

/**
 * @description:
 * @author: yf
 * @date: 2022-09-16 09:25:14
 */
@Repository
public class GetOneReduceDetailInfoCommand implements BaseCommand<String, Result<ReduceDtailInfoResponse>> {
    @Autowired
    private ReduceOperateMapper reduceOperateMapper;

    @Autowired
    private GetReduceDetailCommand getReduceDetailCommand;

    @Override
    public Result<ReduceDtailInfoResponse> execute(String caseId) {
        ReduceOperate reduceLog = reduceOperateMapper.getLogByCaseId(caseId);
        //获取根据id获取详情
        if ((reduceLog != null) && (StringUtil.isNotBlank(reduceLog.getId()))) {
            return getReduceDetailCommand.execute(reduceLog.getId());
        }
        return Result.ok(new ReduceDtailInfoResponse());
    }
}
